package com.czy.fx.day1.pane.AnchorPane;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;

public class demo2 extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        primaryStage.setTitle("标题");
        primaryStage.setWidth(800);
        primaryStage.setHeight(800);
        AnchorPane anchorPane = new AnchorPane();
        Group group1 = new Group();
        Group group2 = new Group();
        //anchorPane 管理 group1和group2
        anchorPane.getChildren().add(group1);
        anchorPane.getChildren().add(group2);

        primaryStage.setScene(new Scene(anchorPane));

        anchorPane.setStyle("-fx-background-color: #EE1169");
        Button b1 = new Button("b1");
        Button b2 = new Button("b2");
        Button b3 = new Button("b3");
        Button b4 = new Button("b4");

        //group1 管理 b1和b2
        group1.getChildren().addAll(b1,b2);
        //group2 管理 b3和b4
        group2.getChildren().addAll(b3,b4);


        //响应式布局 管理子组件的位置，设置上边界距离
        AnchorPane.setTopAnchor(group1,10.0);
        AnchorPane.setLeftAnchor(group1,10.0);

        AnchorPane.setTopAnchor(group2,50.0);
        AnchorPane.setLeftAnchor(group2,10.0);

        primaryStage.show();
    }
}
